package com.tl.commonlibrary.ui.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.tl.commonlibrary.R;


public class ProgressDialog extends Dialog {
	private TextView hintTView;
	private String message;
	private Context context;

	public ProgressDialog(Context context, String message) {
		super(context, R.style.MyDialog);
		this.message = message;
		this.context = context;

	}

	public ProgressDialog(Context context, int messageResId) {
		super(context, R.style.MyDialog);
		this.context = context;
		if (messageResId > 0) {
			this.message = context.getResources().getString(messageResId);
		}
	}

	public ProgressDialog(Context context) {
		super(context, R.style.MyDialog);
		this.context = context;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public void setMessage(int messageResId) {
		if (messageResId > 0) {
			this.message = context.getResources().getString(messageResId);
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.progress_dialog);
//		DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
//		LinearLayout pbLLayout = (LinearLayout) findViewById(R.id.ll_progress);
//		FrameLayout.LayoutParams layoutParams = (LayoutParams) pbLLayout.getLayoutParams();
//		int size = 0;
//		if (displayMetrics.widthPixels < displayMetrics.heightPixels) {
//			size = displayMetrics.widthPixels *2/ 5;
//		} else {
//			size = displayMetrics.heightPixels *2/ 5;
//		}
//		layoutParams.width = size;
//		layoutParams.height = size*3/5;
//		pbLLayout.setLayoutParams(layoutParams);
		hintTView = (TextView) findViewById(R.id.tv_hint);
		if (message != null) {
			hintTView.setText(message);
		}
	}

	@Override
	public void dismiss() {
		super.dismiss();
	}
}
